do "E:\yungyu\lottery_baby\do\set_environment.do"

clear
set more off

import excel using "$table/Tables.xlsx", clear sheet(Tab2) first

keep in 4/21
keep v7
gen norm = -4 + ceil(_n/2)
replace norm = norm + 1 if norm >= -1

loc N = _N + 2
set obs `N'
replace norm = -1 if norm == .

gen type = mod(_n+1,2)
reshape wide v7, i(norm) j(type)

rename v70 coef
rename v71 se

foreach x in coef se{
	replace `x' = subinstr(`x',"*","",.)
	replace `x' = subinstr(`x',"(","",.)
	replace `x' = subinstr(`x',")","",.)
	destring `x', replace
	recode `x' . = 0
}

gen upper = coef + 1.96 * se
gen lower = coef - 1.96 * se


twoway 	(connect coef norm, ms(O) color(black)) ///
		(rline upper lower norm, lp(dash) color(gs8)), ///
		legend(order(1 "Point Estimate" 2 "95% CI")) ///
		xtitle(Years from Lottery Prize) xlabel(-3(1)6) ///
		ytitle(Effect on Cumulative Number of Children) ylabel(, angle(0) format(%4.2f)) ///
		scheme(s1color) yline(0, lc(black))
		
graph export "$folder/figure/Fig2.eps", as(eps) replace
